<template>
    <div v-loading="isLoading">
        <div class="article-header">
            <span>文章分类</span>
        </div>
        <div class="article-category">
            <div class="category-item" v-for="item, index in articleCategoryList" :key="index"
            @click="handleCategoryClick(item)">
            <div class="title">
                <span>{{ item.name }}</span>
            </div>
        </div>
    </div>
    </div>
</template>

<script>
import { reqArticleCategoryList } from '@/api';


export default {
    name: "article-category",
    props: ['plateId'],
    data() {
        return {
            isLoading: false,
            articleCategoryList: []
        }
    },
    mounted() {
        this.getArticleCategoryList();
    },
    methods: {
        getArticleCategoryList() {
            reqArticleCategoryList({
                pageNum: 1,
                pageSize: 1000
            }).then(res => {
                this.articleCategoryList = res.rows;
            }).catch(error => {
            })
        },
        handleCategoryClick(item) {
            this.$router.push(`/category?categoryId=${item.id}`);
        }
    }
}
</script>

<style scoped>
.article-category {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}

.article-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: bold;
    color: #303133;
}

.category-item {
    display: flex;
    padding: 5px;
    justify-content: center;
}

.category-item:hover {
    background-color: #f5f7fa;
    cursor: pointer;
}

.img {
    margin-right: 10px;
}

.content {
    display: flex;
    flex-direction: column;
}

.title a {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 10px;
}

.other {
    font-size: 14px;
    color: #666;
}
</style>